package com.bob.common;


import cn.hutool.json.JSONObject;
import com.bob.common.bean.CommitInfo;
import com.bob.common.bean.DiffItem;
import com.bob.common.bean.PomEntity;
import com.bob.common.bean.ResourcesRef;

import java.io.File;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

public class DataStore {
    private static DataStore dataStore = new  DataStore();

    private PomEntity parentPomEntity = null;
    // pom 各个节点关系  KEY:artifactId cczyz_app
    private Map<String, PomEntity> pomEntityMap =new ConcurrentHashMap<>(0);
    // POM json KEY:absolutePath F:\dev\cczyz\cczyz\cczyz_app
    //
    private Map<String, JSONObject> pomJsonObject =new ConcurrentHashMap<>(0);
    /**
     * POM key:absolutePath value:artifactId
     * F:\dev\cczyz\cczyz\cczyz_bankcard  cczyz_bankcard
     */
    private Map<String, String> pomAbsolutePathRef =new ConcurrentHashMap<>(0);

    /**
     * 版本差异文件 （不含删除文件）
     */
    private List<DiffItem> diffItems = new ArrayList<>(0);

    /**
     *  git log 提交信息
     */
    private List<CommitInfo> commitInfos = new ArrayList<>(0);
    // 项目根路径
    private String rootDir;

    /**
     * 文件资源映射
     *
     */
    private Set<ResourcesRef> resourcesRefs = new HashSet<>(4);
    /**
     * 补丁存放路径
     */
    private File patchOutPath;


    private Map<String,Object> data = new ConcurrentHashMap<>(16);
    public static DataStore getDataStore() {
        return dataStore;
    }

    public Map<String, PomEntity> getPomEntityMap() {
        return pomEntityMap;
    }


    public String getRootDir() {
        return rootDir;
    }

    public void setRootDir(String rootDir) {
        this.rootDir = rootDir;
    }

    public Map<String, JSONObject> getPomJsonObject() {
        return pomJsonObject;
    }

    public Map<String, String> getPomAbsolutePathRef() {
        return pomAbsolutePathRef;
    }

    public List<DiffItem> getDiffItems() {
        return diffItems;
    }

    public List<CommitInfo> getCommitInfos() {
        return commitInfos;
    }


    public Set<ResourcesRef> getResourcesRefs() {
        return resourcesRefs;
    }

    public File getPatchOutPath() {
        return patchOutPath;
    }

    public void setPatchOutPath(File patchOutPath) {
        this.patchOutPath = patchOutPath;
    }


    public Map<String, Object> getData() {
        return data;
    }

}
